

package jetbrains.buildServer.server.rest.data.util.tree;

import org.jetbrains.annotations.NotNull;

/**
 * Represents a quantitave characteristic of a {@link ScopeTree} node.<br/>
 * For each node in a tree the following statement holds true:<br/>
 * <code>
 *   parentCounters == parent.getChildren().reduce(ZERO, (c1, c2) -> c1.combinedWith(c2));
 * </code>
 */
public interface TreeCounters<COUNTERS_IMPL extends TreeCounters<COUNTERS_IMPL>> {
  /**
   * @return Calculates a combined counters, i.e. this is a generalized addition.
   * @implSpec Implementation must treat <code>this</code> and <code>other</code> as immutable and return a new instance of <code>T</code>.
   */
  COUNTERS_IMPL combinedWith(@NotNull COUNTERS_IMPL other);
}